//
// Delaunay Triangulation
//
// Homework of CG lesson (Fall 2009) in Tsinghua University.
// All rights reserved.
//

#pragma once

#include "point2d.h"

/**
 * The class for Edge.
 */
class Edge
{
// public constructors & destructor
public:
    /**
     * Default constructor without data.
     */
    Edge(void);

// public member functions
public:
    /**
     * Returns the twin edge.
     */
    Edge* twin(void);
    /**
     * Returns the next edge(CCW).
     */
    Edge* next(void);
    /**
     * Returns the previous edge(CCW).
     */
    Edge* prev(void);

// public member functions
public:
    /**
     * Returns the edge from the destination to the origin of the current edge.
     */
    Edge* sym(void);
    /**
     * Returns the next ccw edge around (from) the origin of the current edge.
     */
    Edge* oNext(void);
    /**
     * Returns the next cw edge around (from) the origin of the current edge.
     */
    Edge* oPrev(void);
    /**
     * Returns the next ccw edge around (into) the destination of
     * the current edge.
     */
    Edge* dNext(void);
    /**
     * Returns the next cw edge around (into) the destination of
     * the current edge.
     */
    Edge* dPrev(void);
    /**
     * Returns the ccw edge around the left face following the current edge.
     */
    Edge* lNext(void);
    /**
     * Returns the ccw edge around the left face before the current edge.
     */
    Edge* lPrev(void);
    /**
     * Returns the edge around the right face ccw following the current edge.
     */
    Edge* rNext(void);
    /**
     * Returns the edge around the right face ccw before the current edge.
     */
    Edge* rPrev(void);
    /**
     * Returns the origin of the current edge.
     */
    Point2d* org(void);
    /**
     * Returns the destination of the current edge.
     */
    Point2d* dest(void);
    /**
     * Gets the pointer to the origin.
     */
    const Point2d& org2d(void) const;
    /**
     * Gets the pointer to the destination.
     */
    const Point2d& dest2d(void) const;
    /**
     * Sets the origin with @c org, and the destination with @c des.
     */
    void endPoints(Point2d* org, Point2d* des);
    /**
     * Returns the address of the starting edge.
     */
    void* qEdge(void);

// public data members
public:
    int num;
    Edge* eNext;
    Edge* ePrev;
    Point2d* oData;
};
